import {createApp, reactive} from '/static/scripts/petite-vue.es.js';
import axios from '/static/scripts/axios.js';


const instance = reactive({
    signList: [],
    loading: true,
    get alreadySign() {
        return localStorage.getItem('user') != null;
    },
    fetchList() {

        if(!this.alreadySign){
            console.log('未签到跳过远程获取签到列表');
            return;
        }
        axios.post('/sign/list').then(res => res.data)
            .then(json => {
                instance.signList = json;
                instance.signList.forEach(((item, idx) => {
                    item.idx = idx + 1;
                    item.signInAt = dayjs(item.signInAt).format('YYYY/MM/DD HH:mm:ss');
                }));
                this.loading = false;

            });
    }
});

createApp(instance).mount();